package com.kmair.caiwu.financialexpress.service.impl;

import com.kmair.caiwu.financialexpress.dao.ExpreseDataMapper;
import com.kmair.caiwu.financialexpress.pojo.ExpreseData;
import com.kmair.caiwu.financialexpress.service.DataOperationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ExpreseDataService implements DataOperationService {
    private final ExpreseDataMapper dao;
    private final FinancialExpressFormationService fefDao;

    @Autowired
    public ExpreseDataService(ExpreseDataMapper dao, FinancialExpressFormationService fefDao) {
        this.dao = dao;
        this.fefDao = fefDao;
    }


    @Transactional(propagation = Propagation.REQUIRED)
    public int deleteByPrimaryKey(Integer tId) {
        return dao.deleteByPrimaryKey(tId);
    }


    @Transactional(propagation = Propagation.REQUIRED)
    public int insert(Object record) {
        return dao.insert((ExpreseData) record);
    }

    @Transactional(propagation = Propagation.REQUIRED)
    public int insertSelective(Object record) {
        return dao.insertSelective((ExpreseData) record);
    }

    @Transactional(propagation = Propagation.SUPPORTS)
    public Object selectByPrimaryKey(Integer tId) {
        return dao.selectByPrimaryKey(tId);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public int updateByPrimaryKeySelective(Object record) {
        return dao.updateByPrimaryKeySelective((ExpreseData) record);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public int updateByPrimaryKey(Object record) {
        return dao.updateByPrimaryKey((ExpreseData) record);
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public List selectSelective(Object entity) {
        List<ExpreseData> edl = dao.selectBySelective((ExpreseData) entity);
        return edl;
    }

    @Transactional(propagation = Propagation.SUPPORTS)
    public Double sumActualPrice(String subjectId, String qureyDate) {
        return dao.sumActualPrice(subjectId, qureyDate);
    }

    @Transactional(propagation = Propagation.REQUIRED)
    public void expreseDataInit(String queryDate) {
        dao.expreseDataInit(queryDate);
    }

    @Transactional(propagation = Propagation.SUPPORTS)
    public List<ExpreseData> selectBySubjectIdLength(Integer length, String queryDate) {
        return dao.selectBySubjectIdLength(length, queryDate);
    }

}
